package com.wst.wst_server.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wst.wst_server.entity.Leader;
import com.wst.wst_server.service.ILeaderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * <p>
 * �쵼��¼ 前端控制器
 * </p>
 *
 * @author zyk
 * @since 2023-03-24
 */
@RestController
@RequestMapping("/leader")
public class LeaderController {

    @Autowired
    ILeaderService service;
    @RequestMapping("/getleader")
    public ResponseResult<List<Leader>> getleader(){
        return new ResponseResult<List<Leader>>(200,"ok",service.list());
    }
    @RequestMapping("/getbyoidoryearly")
    public ResponseResult<List<Leader>> getby(@RequestParam Map<String,Object> map){
        QueryWrapper queryWrapper = new QueryWrapper();
        Set<String> keys = map.keySet();
        for (String key : keys) {
            queryWrapper.eq(key,map.get(key));
        }
        return new ResponseResult<List<Leader>>(200,"ok",service.list(queryWrapper));
    }
    @RequestMapping("/getbypage")
    public ResponseResult<IPage<Leader>> getbypage(Integer page,Integer count){
        IPage<Leader> p = new Page<>(page,count);
        return new ResponseResult<IPage<Leader>>(200,"ok",service.page(p));
    }
    @RequestMapping("/getbyid")
    public ResponseResult<Leader> getbyid(Integer id){
        return new ResponseResult<Leader>(200,"ok",service.getById(id));
    }
    @RequestMapping("/byidupdate")
    public ResponseResult updateid(Leader leader){
        System.out.println(leader);
        return new ResponseResult(200,"ok",service.updateById(leader));
    }
    @RequestMapping("/deleteid")
    public ResponseResult deleteid(Integer id){
        return new ResponseResult(200,"ok",service.removeById(id));
    }
    @RequestMapping("/leaderadd")
    public ResponseResult leaderadd(Leader leader){
        return new ResponseResult(200,"ok",service.save(leader));
    }

    @RequestMapping("/get1")
    public ResponseResult get1(@RequestParam Map<String ,Integer> map){
        System.out.println(map);
        List<Integer> ids = new ArrayList<>(map.values());
        return new ResponseResult(200,"ok",service.get1(ids));
    }
    @RequestMapping("/get2")
    public ResponseResult get2(@RequestParam Map<String ,Integer> map){
        System.out.println(map);
        List<Integer> ids = new ArrayList<>(map.values());
        return new ResponseResult(200,"ok",service.get2(ids));
    }
    @RequestMapping("/get3")
    public ResponseResult get3(@RequestParam Map<String ,Integer> map){
        System.out.println(map);
        List<Integer> ids = new ArrayList<>(map.values());
        return new ResponseResult(200,"ok",service.get3(ids));
    }
    @RequestMapping("/get4")
    public ResponseResult get4(@RequestParam Map<String ,Integer> map){
        System.out.println(map);
        List<Integer> ids = new ArrayList<>(map.values());
        return new ResponseResult(200,"ok",service.get4(ids));
    }
    @RequestMapping("/get5")
    public ResponseResult get5(@RequestParam Map<String ,Integer> map){
        System.out.println(map);
        List<Integer> ids = new ArrayList<>(map.values());
        return new ResponseResult(200,"ok",service.get5(ids));
    }
    @RequestMapping("/get6")
    public ResponseResult get6(@RequestParam Map<String ,Integer> map){
        System.out.println(map);
        List<Integer> ids = new ArrayList<>(map.values());
        return new ResponseResult(200,"ok",service.get6(ids));
    }
    @RequestMapping("/get7")
    public ResponseResult get7(@RequestParam Map<String ,Integer> map){
        System.out.println(map);
        List<Integer> ids = new ArrayList<>(map.values());
        return new ResponseResult(200,"ok",service.get7(ids));
    }
    @RequestMapping("/get8")
    public ResponseResult get8(@RequestParam Map<String ,Integer> map){
        System.out.println(map);
        List<Integer> ids = new ArrayList<>(map.values());
        return new ResponseResult(200,"ok",service.get8(ids));
    }
    @RequestMapping("/get9")
    public ResponseResult get9(@RequestParam Map<String ,Integer> map){
        System.out.println(map);
        List<Integer> ids = new ArrayList<>(map.values());
        return new ResponseResult(200,"ok",service.get9(ids));
    }
    @RequestMapping("/get10")
    public ResponseResult get10(@RequestParam Map<String ,Integer> map){
        System.out.println(map);
        List<Integer> ids = new ArrayList<>(map.values());
        return new ResponseResult(200,"ok",service.get10(ids));
    }
    @RequestMapping("/get11")
    public ResponseResult get11(@RequestParam Map<String ,Integer> map){
        System.out.println(map);
        List<Integer> ids = new ArrayList<>(map.values());
        return new ResponseResult(200,"ok",service.get11(ids));
    }
    @RequestMapping("/get12")
    public ResponseResult get12(){
        return new ResponseResult(200,"ok",service.get12());
    }
}
